package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"net/http"
	"os"
)

func main() {
	if len(os.Args) < 1 {
		fmt.Printf("usage ./node_dir config\n")
		return
	}

	url := "http://" + os.Args[1] + ":8000/config"
	contentType := "application/json;charset=utf-8"

	b := []byte("refresh")
	body := bytes.NewBuffer(b)

	resp, err := http.Post(url, contentType, body)
	if err != nil {
		fmt.Println("Get failed:", err)
		return
	}

	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		fmt.Println("statuscode:", resp.StatusCode)

	}

	content, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		fmt.Println("Read failed:", err)
	}

	fmt.Println("Refresh :", string(content))

}
